package com.kjc.demo.basic.listener;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONObject;
import com.kjc.demo.basic.config.RabbitConfig;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class HelloQueueListener {
	
	@RabbitListener(queues = {"hello"})
    public void processPaymentOrderMessage(Message message) {
        byte[] input = message.getBody();
        String paymentOrderDTO = JSONObject.parseObject(input, String.class);
        
        log.info("【订单-消费者】支付订单消息：{}", paymentOrderDTO);

    }
	
	@RabbitListener(queues = {"topic.message"})
    public void topicMessage(Message message) {
        byte[] input = message.getBody();
//        String paymentOrderDTO = JSONObject.parseObject(input, String.class);
        
        log.info("【订单-消费者】支付订单消息：{}", new String(input));

    }
	
	@RabbitListener(queues = {"topic.messages"})
    public void topicMessages(Message message) {
        byte[] input = message.getBody();
        
//        String paymentOrderDTO = JSONObject.parseObject(input, String.class);
        
        log.info("【订单-消费者】支付订单消息：{}", new String(input));

    }
	
	@RabbitListener(queues = {"fanout.A"})
    public void fanouta(Message message) {
        byte[] input = message.getBody();
        
//        String paymentOrderDTO = JSONObject.parseObject(input, String.class);
        
        log.info("fanouta：{}", new String(input));

    }
	
	@RabbitListener(queues = {"fanout.B"})
    public void fanoutb(Message message) {
        byte[] input = message.getBody();
        
//        String paymentOrderDTO = JSONObject.parseObject(input, String.class);
        
        log.info("fanoutb：{}", new String(input));

    }
	
	@RabbitListener(queues = {"fanout.C"})
    public void fanoutc(Message message) {
        byte[] input = message.getBody();
        
//        String paymentOrderDTO = JSONObject.parseObject(input, String.class);
        
        log.info("fanoutc：{}", new String(input));

    }
}
